package com.jeomo.mem.provider.web;

import com.jeomo.common.core.result.CommonResult;
import com.jeomo.common.core.util.BeanCopyUtil;
import com.jeomo.mem.provider.request.SysAdminMailReq;
import com.jeomo.mem.starter.sysoption.SysAdminMailOption;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 积分有效期
 */
@RestController
@RequestMapping("sysAdmin")
public class SysAdminMailController {

    @Resource
    private SysAdminMailOption sysAdminMailOption;


    @PostMapping("mail")
    public CommonResult saveOption(@RequestBody SysAdminMailReq sysAdminMailReq){

        BeanCopyUtil.copyProperties(sysAdminMailReq,sysAdminMailOption);
        boolean save = sysAdminMailOption.save();
        return save?CommonResult.success("保存成功"):CommonResult.failure("保存失败");
    }

    @GetMapping("mail")
    public CommonResult<SysAdminMailReq> getOption(){
        sysAdminMailOption.load();
        SysAdminMailReq sysAdminMailReq = BeanCopyUtil.copyProperties(sysAdminMailOption, SysAdminMailReq.class);
        return CommonResult.success(sysAdminMailReq);
    }

}
